import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class PlayWithStream {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("'+7913152','2020-05-25 00:00:25'");
        list.add("'8912345','2020-05-25 00:01:49'");
        list.add("'916952','2020-05-25 00:01:55'");
        System.out.println(list);
        List<String> collect = list.stream().map(PlayWithStreamss::doTransform).collect(Collectors.toList());
        System.out.println(collect);
    }

    public static String doTransform(String phone1) {
        String[] a = phone1.split(",");
        String phone = a[0];
        boolean flag2 = phone.substring(0, 1).matches("[8]");
        String finaloutput = "";
        if (!flag2) {
            int len = phone.length();
            if (len > 7) {
                String sub = phone.substring(0, phone.length() - 6);
                String newStr = phone.replace(sub, "");
                finaloutput = "8".concat(newStr);
            } else {
                finaloutput = "8".concat(phone);
            }
        }
        return finaloutput + "," + a[1];
    }
}